//
//  NSDictionary+NSDictionary_Ext.m
//  HDWenBo
//
//  Created by mac on 2017/4/13.
//  Copyright © 2017年 hengdawb. All rights reserved.
//

#import "NSDictionary+NSDictionary_Ext.h"

@implementation NSDictionary (NSDictionary_Ext)
+(NSDictionary *)nullDic:(NSDictionary *)myDic

{
    
    NSArray *keyArr = [myDic allKeys];
    
    NSMutableDictionary *resDic = [[NSMutableDictionary alloc]init];
    
    for (int i = 0; i < keyArr.count; i ++)
        
    {
        
        id obj = [myDic objectForKey:keyArr[i]];
        obj = [self changeType:obj];
        [resDic setObject:obj forKey:keyArr[i]];
        
    }
    
    return resDic;
    
}

+(id)changeType:(id)myObj

{
    
    if ([myObj isKindOfClass:[NSDictionary class]])
        
    {
        
        return [self nullDic:myObj];
        
    }
    
    else if([myObj isKindOfClass:[NSArray class]])
        
    {
        
        return [self nullArr:myObj];
        
    }
    
    else if([myObj isKindOfClass:[NSString class]])
        
    {
        
        return [self stringToString:myObj];
        
    }
    
    else if([myObj isKindOfClass:[NSNull class]])
        
    {
        
        return [self nullToString];
        
    }
    
    else
        
    {
        
        return myObj;
        
    }
    
}

+(NSArray *)nullArr:(NSArray *)myArr

{
    
    NSMutableArray *resArr = [[NSMutableArray alloc] init];
    
    for (int i = 0; i < myArr.count; i ++)
        
    {
        
        id obj = myArr[i];
        
        
        
        obj = [self changeType:obj];
        
        
        
        [resArr addObject:obj];
        
    }
    
    return resArr;
    
}



//将NSString类型的原路返回

+(NSString *)stringToString:(NSString *)string

{
    if (string == nil ||string.length==0) {
        return @"";
    }else{
        
        return string;
    }
    
}



//将Null类型的项目转化成@""

+(NSString *)nullToString

{
    
    return @"";
    
}



@end
